package mylab.io.base.model;

import mylab.io.base.model.impl.RxtxEndpoint;
import mylab.io.base.model.impl.SocketEndpoint;
import mylab.io.base.model.impl.UriEndpoint;

import java.net.InetSocketAddress;

public interface Endpoint {
    String getId();

    static SocketEndpoint from(InetSocketAddress address) {
        return new SocketEndpoint(address.getHostName(), address.getPort());
    }

    static SocketEndpoint from(String ip, int port) {
        return new SocketEndpoint(ip, port);
    }

    static SocketEndpoint from(int port) {
        return new SocketEndpoint(port);
    }

    static UriEndpoint fromUri(String uri) {
        return new UriEndpoint(uri);
    }

    static RxtxEndpoint fromSerialPort(String serialPort) {
        return new RxtxEndpoint(serialPort);
    }
}
